from django.db import models

# Create your models here.

# 类别分类
class Cate(models.Model):
    name = models.CharField('类别类别',max_length=50)

    cid = models.ForeignKey('self',on_delete=models.CASCADE,null=True,blank=True,related_name='subs')

    def __str__(self):
        return self.name

    class Meta:
        db_table = 'cate'


# 分类分组

class Group(models.Model):
    """
    分类分组
    """
    name = models.CharField("分类分组", max_length=30)
    # 一级类别
    cate = models.OneToOneField(Cate, on_delete=models.CASCADE)
    group_url = models.CharField("频道的地址链接", max_length=100, default="http://jd.com")
    sequence = models.IntegerField(verbose_name="组内的顺序", default=0)

    class Meta:
        db_table = 'cate_group'

    def __str__(self):
        return self.name












